var app = getApp();
Component({
    properties: {
        itemout: Object,
        params: Object,
        istag: Number,
        hpadding: Number,
        hgpadding: Number,
    },
    data: {
        itemidx: 1,
    },
    options: {
        addGlobalClass: true,
    },
    ready() {
        var params = this.data.itemout.params;

        this.setData({
            actsid: params.actsid > 0 ? params.actsid : 0
        })
    },
    methods: {
        ended(e){
            var url = e.target.id
            var videoContext = wx.createVideoContext(url, this) //这里对应的视频id
            videoContext.seek(0.1)
        },
        play(e) {
            var url = e.target.id
            const gv = app.globalData.videoNumber
            if (url != gv && gv != null) {
                var videoContext = wx.createVideoContext(gv, this) //这里对应的视频id
                videoContext.pause()
            }
            app.globalData.videoNumber = url
        },
        // 点击立即购买
        buyit() {
            this.triggerEvent('buyit');
        },
        // 跳转到商铺详情
        goShop(e){
            app.com.navigateto(e);
        },
        setlist(e) {
            this.setData({
                'itemout.params.data': e.detail.list,
                'itemout.params.actsid': e.detail.actsid,
            })
        },
        changeswiper(e) {
            this.setData({
                itemidx: e.detail.current * 1 + 1
            })
        },
        onChangetime(e) {
            var index = e.currentTarget.dataset.index;
            this.setData({
                ['itemout.params.data[' + index + '].uptime']: e.detail
            })
        },
        navigateto: function (e) {
            var self = this;
            if (self.data.params.indexmes == 1 || !wx.requestSubscribeMessage) {
                app.com.navigateto(e);
            } else {
                wx.requestSubscribeMessage({
                    tmplIds: self.data.params.submess,
                    complete: function () {
                        app.com.navigateto(e);
                    }
                })
            }
        },
    }
});